#ifndef __MUTEXLOCK_H_
#define __MUTEXLOCK_H_

#include "Noncopyable.hpp"
#include <pthread.h>

namespace ln{

class MutexLock
:Noncopyable
{
public:
    MutexLock();
    ~MutexLock();
    void lock();
    void unlock();
    pthread_mutex_t * getMutexLockPtr();

private:
    pthread_mutex_t _mutex;
};

class MutexAutoRelease{
public:
    MutexAutoRelease(MutexLock & m)
    :_mutex(m)
    {
        _mutex.lock();
    }

    ~MutexAutoRelease(){
        _mutex.unlock();    
    }

private:
    MutexLock & _mutex;
};

}//end of namespace ln


#endif

